<!-- LoadingComponent.vue -->
<template>
  <div class="loading-mask">
    <div class="loading-spinner">
      <div class="flex-col">
        <div class="spinner"></div>
        <p v-if="text" class="loading-text">{{ text }}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    text: {
      type: String,
      default: '加载中...',
    },
  },
};
</script>

<style scoped>
.flex-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.loading-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  background-color: rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  opacity: 0;
  overflow: hidden;
}
.show {
  display: block;
  opacity: 1;
  width: 100%;
  height: 100%;
  transition: opacity 0.4s;
}

.loading-spinner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-radius: 50%;
  border-top: 3px solid #3498db;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 10px;
  color: #666;
  font-size: 14px;
}
</style>
